import React from 'react'
import { Modal, } from 'antd';
import {withRouter} from 'react-router-dom'
import { ExclamationCircleOutlined } from '@ant-design/icons';

import './header.less'
import memoryUtils from '../../utils/memoryUtils'
import storageUtils from '../../utils/storageUtils'

class Header extends React.Component{
    state=({

    })

    logout = ()=>{
        Modal.confirm({
            title: '确定退出?',
            icon: <ExclamationCircleOutlined />,
            onOk:()=> {
              console.log('OK');
              //删除保存的user数据
                storageUtils.removeUser()
              //跳转到login
              this.props.history.replace('/login')
            }
          })
    }
    render(){
        return (
            <div className="header">
                <div className='header-top'>
                    <span>欢迎，admin</span>
                    <a href="javascript:" onClick={this.logout}>退出</a>
                </div>
                <div className='header-bottom'>2</div>
            </div>
        )
    }

}

export default withRouter(Header)